<!DOCTYPE html>
<html>
<body>
<p>This test ensures navigation is forbidden while beforeunload event is being fired. You should see PASS 1/2 and PASS 2/2 below:</p>
<pre id="log">FAIL</pre>
<script>

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.dumpChildFrames();
    testRunner.waitUntilDone();
}

var log = document.getElementById('log');

function test(iframe) {
    if (iframe.done) {
        if (iframe.halfPassed) {
            iframe.contentWindow.location.href = 'resources/before-unload-in-subframe-destination.html';            
            iframe.halfPassed = false;
        }
        return;
    }
    iframe.done = true;
    iframe.contentWindow.location.href = 'resources/before-unload-in-subframe-child.html';
}

function fired(contentWindow) {
    location.href = 'resources/before-unload-in-subframe-fail.html';
    contentWindow.location.href = 'resources/before-unload-in-subframe-fail.html';
    log.innerHTML = 'PASS 1/2';
    contentWindow.frameElement.halfPassed = true;
}

</script>
<iframe onload="test(this);" src="resources/before-unload-in-subframe-child.html"></iframe>
</body>
</html>
